import { createApp } from 'vue';
import dayjs from 'dayjs';
import App from './App.vue';
import router from './router';
import { store, key } from './store';
import Auth from '/@/components/auth/auth.vue';
import ImageUpload from '/@/components/ImageUpload/index.vue';
import ImageUploadCOS from '/@/components/ImageUploadCOS/index.vue';
import ImageUploadDraggableCOS from '/@/components/ImageUploadDraggableCOS/index.vue';
import Pagination from '/@/components/pagination/index.vue';
import RightToolbar from '/@/components/rightToolbar/index.vue';
import { directive } from '/@/utils/directive';
import { i18n } from '/@/i18n/index';
import { globalComponentSize } from '/@/utils/componentSize';

import ElementPlus from 'element-plus';
import zhCn from 'element-plus/es/locale/lang/zh-cn';
import 'element-plus/dist/index.css';
import 'dayjs/locale/zh-cn';
import '/@/theme/index.scss';
import mitt from 'mitt';
import screenShort from 'vue-web-screen-shot';
import VueGridLayout from 'vue-grid-layout';

const app = createApp(App);
app
	.component('ImageUpload', ImageUpload)
	.component('ImageUploadCOS', ImageUploadCOS)
	.component('ImageUploadDraggableCOS', ImageUploadDraggableCOS)
	.component('Auth', Auth)
	.component('PaginationComponent', Pagination)
	.component('RightToolbar', RightToolbar)
	.use(router)
	.use(store, key)
	.use(ElementPlus, { i18n: i18n.global.t, size: globalComponentSize ? globalComponentSize : 'mini', locale: zhCn })
	.use(i18n)
	.use(screenShort, { enableWebRtc: false })
	.use(VueGridLayout)
	.mount('#app');

app.config.globalProperties.dayjs = dayjs;
const globalProperties = {
	mittBus: mitt(),
	i18n,
};
//必须合并vue默认的变量，否则有问题
app.config.globalProperties = Object.assign(app.config.globalProperties, globalProperties);

directive(app);
